home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue39 / Clinic / additmu2.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-07-15  |  1.2 KB  |  51 lines

  1. unit Additmu2;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils;
  7.  
  8. type
  9.   EShellError = class(Exception);
  10.  
  11. procedure CreateShortCut(const Folder, Description, Path, Arguments,
  12.   Directory, IconPath: String; IconIndex: Integer; ShowMin: Boolean);
  13.  
  14. implementation
  15.  
  16. uses
  17.   DdeMan;
  18.  
  19. procedure CreateShortCut(const Folder, Description, Path, Arguments,
  20.   Directory, IconPath: String; IconIndex: Integer; ShowMin: Boolean);
  21. var
  22.   Cmd: array[0..255] of Char;
  23. begin
  24.   with TDdeClientConv.Create(nil) do
  25.     try
  26.       SetLink('ProgMan', '');
  27.       OpenLink;
  28.       try
  29.         StrPCopy(Cmd, Format('[CreateGroup(%s)]'#13#10, [Folder]));
  30.         ExecuteMacro(Cmd, False);
  31.         { AddItem(CmdLine, Description, IconFile, IconIndex, X, Y, DefDir, Hotkey, Minimize }
  32.         StrPCopy(Cmd, Format('[AddItem(%s %s, %s, %s, %d, , , %s, , 0)]'#13#10,
  33.           [Path, Arguments, Description, IconPath, IconIndex, Directory]));
  34.         if not ExecuteMacro(Cmd, False) then
  35.           raise EShellError.Create('Unable to create item.')
  36.       finally
  37.         CloseLink
  38.       end
  39.     finally
  40.       Free
  41.     end;
  42. end;
  43.  
  44. end.
  45. object DDEClient: TDdeClientConv
  46.   DdeService = 'ProgMan'
  47.   LinkInfo = (
  48.     'Service ProgMan'
  49.     'Topic ')
  50. end
  51.